<template>

    <div class="app-container">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
            label-width="68px">
            <el-form-item label="单据号" prop="nos">
                <el-input v-model="queryParams.nos" placeholder="请输入单据号" clearable @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="订单编号" prop="projectNo">
                <el-input v-model="queryParams.projectNo" placeholder="请输入订单编号" clearable
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="产品编码" prop="code">
                <el-input v-model="queryParams.code" placeholder="请输入产品编码" clearable
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="产品名称" prop="goodsName">
                <el-input v-model="queryParams.params['goodsName']" placeholder="请输入产品名称" clearable
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="产品型号" prop="goodsModel">
                <el-input v-model="queryParams.params['goodsModel']" placeholder="请输入产品型号" clearable
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="客户名称" prop="customerName">
                <el-input v-model="queryParams.customerName" placeholder="请输入客户名称" clearable
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="销售员" prop="saleName">
                <el-input v-model="queryParams.saleName" placeholder="请输入销售人姓名" clearable
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="是否自制" prop="isdo">
                <el-select v-model="queryParams.isdo" placeholder="是否自制" clearable style="width: 130px">
                    <el-option v-for="dict in dict.type.isdo" :key="dict.value" :label="dict.label"
                        :value="dict.value" />
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
        </el-form>

        <el-table border v-loading="loading" :data="dataList" @selection-change="handleSelectionChange" ref="table"
            :max-height="tableMaxHeight" @sort-change="handleSortChange">
            <el-table-column type="selection" width="55" align="center" />
            <el-table-column sortable label="编码" align="center" prop="nos" />
            <el-table-column sortable label="名称" align="center" prop="projectNo" />
            <el-table-column sortable label="摘要" align="center" prop="params.goodsCode" />
            <el-table-column sortable label="单据类型" align="center" prop="params.goodsName" />
            <el-table-column sortable label="单据号" align="center" prop="params.goodsModel" />
            <el-table-column sortable label="订单号" align="center" prop="daohuoCount" />
            <el-table-column label="币种" align="center" prop="dun" />
            <el-table-column label="本期应付" align="center" prop="goodsBuyPrice" />
            <el-table-column label="本期付款" align="center" prop="goodsBuyTotal" />
            <el-table-column sortable label="余额" align="center" prop="unit" />
            <el-table-column sortable label="到期日" align="center" prop="customerName" show-overflow-tooltip />
            <el-table-column sortable label="自定义项1" align="center" prop="saleName" />
            <el-table-column sortable label="检验部门" align="center" prop="zhijianName" />
            <el-table-column sortable label="检验员" align="center" prop="zhijianDate" />
            <!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                <template slot-scope="scope">
                    <el-button size="mini" type="text" icon="el-icon-document"
                        @click="handleQualityTest(scope.row)">质量检验</el-button>
                    <el-button @click="modifyRemark(scope.row)" icon="el-icon-view" size="mini" type="text">
                        修改备注
                    </el-button>
                    <el-button @click="bohui(scope.row)" icon="el-icon-view" size="mini" type="text">
                        驳回
                    </el-button>
                </template>
            </el-table-column> -->
        </el-table>
        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize" @pagination="getList" />
    </div>
</template>

<script>
import { deleteAction, getAction } from '@/api/manage'

export default {
    name: "lvCuRuKuDetails",
    dicts: ['isdo', 'goods_type', 'churuku_type', 'storage_state'],
    data() {
        return {
            // 遮罩层
            loading: true,
            activeName: "first",
            // 弹出层标题
            title: "",
            // 表单参数
            form: {},
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            // 采购单表格数据
            dataList: [],
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                params: {},
                nos: null,
                projectId: null,
                projectNo: null,
                code: null,
                customerName: null,
                saleName: null,
                //status: "1",
                //type: "0",
                isZhijian: "1",
                parentId: null,
                orderByColumn: "goods_id",
                isAsc: "asc",
            },
            rowData: {},
            url: {
                list: '/lvRukumingxi/lvRukumingxi/list',
                ruku: '/lvRukumingxi/lvRukumingxi/ruku/',
            },
            tableMaxHeight: window.innerHeight - 320,
        };
    },
    created() {
        this.getList();
        window.addEventListener('resize', this.getTableHeight);
    },
    methods: {
        /** 查询采购单列表 */
        getList() {
            this.loading = true;
            getAction(this.url.list, this.queryParams).then(response => {
                this.dataList = response.rows;
                this.total = response.total;
                this.loading = false;
            });
        },
        getTableHeight() {
            this.tableHeight = window.innerHeight - 320
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList();
        },
        /** 排序触发事件 */
        handleSortChange(column, prop, order) {
            this.queryParams.orderByColumn = column.prop;
            this.queryParams.isAsc = column.order;
            this.handleQuery();
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.resetForm("queryForm");
            this.handleQuery();

        },
        // 多选框选中数据
        handleSelectionChange(selection) {
            this.ids = selection.map(item => item.id)
            this.single = selection.length !== 1
            this.multiple = !selection.length
        },
    }
};
</script>
